package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanhua.dubbo.server.QuestionService;
import com.tanhua.model.domain.Question;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class QuestionApiImpl implements QuestionApi{
    @Autowired
    private QuestionService questionService;

    @Override
    public Question getByUserId(Long userId) {
        LambdaQueryWrapper<Question> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Question::getUserId, userId);
        return questionService.getOne(queryWrapper);
    }

    @Override
    public void save(Question question) {
        questionService.save(question);
    }

    @Override
    public void updateQuestions(Question question) {
        questionService.updateById(question);
    }

}
